using System;
using System.Collections.Generic;
using System.Text;
using Fodee.DataEntity;
using System.Data.Common;
using System.Data;

namespace Fodee.DataAccess
{
public class fodOrderDA : FodeeDABase
{
public fodOrderDA()
{
}

public bool Insert(FodeeDataSet ds, DbTransaction dbTransaction)
{
DbCommand command = Db.GetStoredProcCommand("P_fod_Order_I");
Db.AddOutParameter(command, "@ID", System.Data.DbType.Int32, 8);
Db.AddInParameter(command, "@BillID", System.Data.DbType.Int32, "BillID", DataRowVersion.Current);
Db.AddInParameter(command, "@TableID", System.Data.DbType.Int32, "TableID", DataRowVersion.Current);
Db.AddInParameter(command, "@StaffID", System.Data.DbType.Int32, "StaffID", DataRowVersion.Current);
Db.AddInParameter(command, "@MemberID", System.Data.DbType.Int32, "MemberID", DataRowVersion.Current);
Db.AddInParameter(command, "@OrderNum", System.Data.DbType.String, "OrderNum", DataRowVersion.Current);
Db.AddInParameter(command, "@OrderCustomerCount", System.Data.DbType.Int32, "OrderCustomerCount", DataRowVersion.Current);
Db.AddInParameter(command, "@OrderStatus", System.Data.DbType.Int32, "OrderStatus", DataRowVersion.Current);
Db.AddInParameter(command, "@OrderStartTime", System.Data.DbType.DateTime, "OrderStartTime", DataRowVersion.Current);
Db.AddInParameter(command, "@OrderRemarks", System.Data.DbType.String, "OrderRemarks", DataRowVersion.Current);
Db.AddInParameter(command, "@VersionNo", System.Data.DbType.Byte, "VersionNo", DataRowVersion.Current);
Db.AddInParameter(command, "@CreatedBy", System.Data.DbType.Int32, "CreatedBy", DataRowVersion.Current);
Db.AddInParameter(command, "@CreatedTime", System.Data.DbType.DateTime, "CreatedTime", DataRowVersion.Current);
Db.AddInParameter(command, "@UpdatedBy", System.Data.DbType.Int32, "UpdatedBy", DataRowVersion.Current);
Db.AddInParameter(command, "@UpdatedTime", System.Data.DbType.DateTime, "UpdatedTime", DataRowVersion.Current);
int result = Db.UpdateDataSet(ds, ds.fod_Order.TableName, command, null, null, dbTransaction);
 if (result > 0)
return true;
return false;
}

public int Add(FodeeDataSet ds, DbTransaction dbTransaction)
{
DbCommand command = Db.GetStoredProcCommand("P_fod_Order_I");
Db.AddOutParameter(command, "@ID", System.Data.DbType.Int32, 8);
Db.AddInParameter(command, "@BillID", System.Data.DbType.Int32, "BillID", DataRowVersion.Current);
Db.AddInParameter(command, "@TableID", System.Data.DbType.Int32, "TableID", DataRowVersion.Current);
Db.AddInParameter(command, "@StaffID", System.Data.DbType.Int32, "StaffID", DataRowVersion.Current);
Db.AddInParameter(command, "@MemberID", System.Data.DbType.Int32, "MemberID", DataRowVersion.Current);
Db.AddInParameter(command, "@OrderNum", System.Data.DbType.String, "OrderNum", DataRowVersion.Current);
Db.AddInParameter(command, "@OrderCustomerCount", System.Data.DbType.Int32, "OrderCustomerCount", DataRowVersion.Current);
Db.AddInParameter(command, "@OrderStatus", System.Data.DbType.Int32, "OrderStatus", DataRowVersion.Current);
Db.AddInParameter(command, "@OrderStartTime", System.Data.DbType.DateTime, "OrderStartTime", DataRowVersion.Current);
Db.AddInParameter(command, "@OrderRemarks", System.Data.DbType.String, "OrderRemarks", DataRowVersion.Current);
Db.AddInParameter(command, "@VersionNo", System.Data.DbType.Byte, "VersionNo", DataRowVersion.Current);
Db.AddInParameter(command, "@CreatedBy", System.Data.DbType.Int32, "CreatedBy", DataRowVersion.Current);
Db.AddInParameter(command, "@CreatedTime", System.Data.DbType.DateTime, "CreatedTime", DataRowVersion.Current);
Db.AddInParameter(command, "@UpdatedBy", System.Data.DbType.Int32, "UpdatedBy", DataRowVersion.Current);
Db.AddInParameter(command, "@UpdatedTime", System.Data.DbType.DateTime, "UpdatedTime", DataRowVersion.Current);
Db.UpdateDataSet(ds, ds.fod_Order.TableName, command, null, null, dbTransaction);
int result = int.Parse(Db.GetParameterValue(command, "@ID").ToString());
return result;
}

public bool Update(FodeeDataSet ds, DbTransaction dbTransaction)
{
DbCommand command = Db.GetStoredProcCommand("P_fod_Order_U");
Db.AddInParameter(command, "@ID", System.Data.DbType.Int32, "ID", DataRowVersion.Current);
Db.AddInParameter(command, "@BillID", System.Data.DbType.Int32, "BillID", DataRowVersion.Current);
Db.AddInParameter(command, "@TableID", System.Data.DbType.Int32, "TableID", DataRowVersion.Current);
Db.AddInParameter(command, "@StaffID", System.Data.DbType.Int32, "StaffID", DataRowVersion.Current);
Db.AddInParameter(command, "@MemberID", System.Data.DbType.Int32, "MemberID", DataRowVersion.Current);
Db.AddInParameter(command, "@OrderNum", System.Data.DbType.String, "OrderNum", DataRowVersion.Current);
Db.AddInParameter(command, "@OrderCustomerCount", System.Data.DbType.Int32, "OrderCustomerCount", DataRowVersion.Current);
Db.AddInParameter(command, "@OrderStatus", System.Data.DbType.Int32, "OrderStatus", DataRowVersion.Current);
Db.AddInParameter(command, "@OrderStartTime", System.Data.DbType.DateTime, "OrderStartTime", DataRowVersion.Current);
Db.AddInParameter(command, "@OrderRemarks", System.Data.DbType.String, "OrderRemarks", DataRowVersion.Current);
Db.AddInParameter(command, "@VersionNo", System.Data.DbType.Byte, "VersionNo", DataRowVersion.Current);
Db.AddInParameter(command, "@CreatedBy", System.Data.DbType.Int32, "CreatedBy", DataRowVersion.Current);
Db.AddInParameter(command, "@CreatedTime", System.Data.DbType.DateTime, "CreatedTime", DataRowVersion.Current);
Db.AddInParameter(command, "@UpdatedBy", System.Data.DbType.Int32, "UpdatedBy", DataRowVersion.Current);
Db.AddInParameter(command, "@UpdatedTime", System.Data.DbType.DateTime, "UpdatedTime", DataRowVersion.Current);
int result = Db.UpdateDataSet(ds, ds.fod_Order.TableName, null, command, null, dbTransaction);
 if (result > 0)
return true;
return false;
}

public bool Delete(int id, DbTransaction dbTransaction)
{
DbCommand command = Db.GetStoredProcCommand("P_fod_Order_D");
Db.AddInParameter(command, "@ID", System.Data.DbType.Int32, id);
int result = Db.ExecuteNonQuery(command, dbTransaction);
 if (result > 0)
return true;
return false;
}

 public FodeeDataSet GetByID(int id)
{
FodeeDataSet ds = new FodeeDataSet();
DbCommand command = Db.GetStoredProcCommand("P_fod_Order_S");
Db.AddInParameter(command, "@ID", System.Data.DbType.Int32, id);
Db.LoadDataSet(command, ds,ds.fod_Order.TableName);
return ds;
}

 public FodeeDataSet GetAll()
{
FodeeDataSet ds = new FodeeDataSet();
DbCommand command = Db.GetStoredProcCommand("P_fod_Order_A");
Db.LoadDataSet(command, ds,ds.fod_Order.TableName);
return ds;
}


}
}


